﻿using Coldairarrow.Business.FP;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.FP;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.FP
{
    [Route("/FP/[controller]/[action]")]
    public class Base_OverFlowController : BaseApiController
    {
        #region DI

        public Base_OverFlowController(IBase_OverFlowBusiness base_OverFlowBus)
        {
            _base_OverFlowBus = base_OverFlowBus;
        }

        IBase_OverFlowBusiness _base_OverFlowBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_OverFlow>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_OverFlowBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_OverFlow> GetTheData(IdInputDTO input)
        {

            return await _base_OverFlowBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 钉钉获取任务清单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<Base_OverFlowTask>> GetTaskDataList()
        {
            return await _base_OverFlowBus.GetTaskDataListAsync();
        }

        /// <summary>
        /// 获取表单详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<OverFlowTaskDTO> GetTaskInfoData(OverFlowInputDTO input)
        {
            return await _base_OverFlowBus.GetTaskInfoDataAsync(input);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(FP_FlowProcessDTO data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_OverFlowBus.AddDataAsync(data);
            }
            else
            {
                await _base_OverFlowBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_OverFlowBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 审批通过
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task ApprovedData(OverFlowInputDTO input)
        {
            await _base_OverFlowBus.ApprovedDataAsync(input);
        }

        /// <summary>
        /// 审批驳回
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task RejectData(OverFlowInputDTO input)
        {
            await _base_OverFlowBus.RejectDataAsync(input);
        }

        /// <summary>
        /// 通过项目楼号获取正在进行的任务清单
        /// </summary>
        /// <param name="ProjectId">项目id</param>
        /// <param name="BuildingnumberId">楼号id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<Base_OverFlowTask>> GetTaskDataListInfoAsync(string ProjectId, string BuildingnumberId) {
            List<Base_OverFlowTask> list =await _base_OverFlowBus.GetTaskDataListInfoAsync(ProjectId,BuildingnumberId);
            return list;
        }
        [HttpPost]
        public async Task<string> GetTheBillType(string Id) {
           return await _base_OverFlowBus.GetTheBillType(Id);
        }
        [HttpPost]
        public async Task<int?> GetTheDesignState(string Id) {
            return await _base_OverFlowBus.GetTheDesignState(Id);
        }
        #endregion
    }
}